/*
 * =====================================================================================
 *
 *       Filename:  debug.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2019年05月08日 20时17分39秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */

#ifndef _UTIL_DEBUG_H_
#define _UTIL_DEBUG_H_
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>

extern int errno;

extern int debug_log(const char *fmt, ...);
extern int debug_err(const char *fmt, ...);
extern int debug_print(const char *fmt, ...);
extern int  get_debug_switch();
extern void set_debug_switch(int);

#ifdef UTIL_DEBUG_LOG_DEBUG
#define UTIL_DEBUG_LOG() \
    debug_print("File:%s, Line:%d, Func: %s()\n", __FILE__, __LINE__, __func__)
#else
    #define UTIL_DEBUG_LOG()
#endif

#define DEBUG_ERR(call_func, err_func) \
    debug_err("%s(), %s(), %s\n", call_func, err_func, strerror(errno))

#endif

